#pragma once
#include "DXAMLCommon.h"
#include "CPanel.h"

class VisualTree;

class CFocusManager;
class CLayoutManager;
class CPopupRoot;

class CRootVisual :
	public CPanel
{

private: 
	CRootVisual(CCoreServices * pCore);
	virtual ~CRootVisual();
	HRESULT RegisterTabProcessEventHandler();
	HRESULT UnregisterTabProcessEventHandler();
	HRESULT RegisterContextMenuOpeningEventHandler();
	HRESULT UnregisterContextMenuOpeningEventHandler();
	HRESULT RegisterManipulationInertiaProcessingEventHandler();
	HRESULT UnregisterManipulationInertiaProcessingEventHandler();
	HRESULT RegisterRightTappedEventHandler();
	HRESULT UnregisterRightTappedEventHandler();
public: 
	static HRESULT Create(CDependencyObject * * ppObject, CREATEPARAMETERS * pCreate);
	virtual XUINT32 GetTypeIndex() const;
	virtual XBOOL ParticipatesInManagedTreeInternal();
	virtual XBOOL GetIsLayoutElement();
	virtual void Shutdown();
	static HRESULT TabProcessingEventListener(struct Xcp_IDependencyObject * pSender, struct Xcp_IDependencyObject * pEventArgs);
	static HRESULT ContextMenuOpeningEventListener(struct Xcp_IDependencyObject * pSender, struct Xcp_IDependencyObject * pEventArgs);
	static HRESULT ManipulationInertiaProcessingEventListener(struct Xcp_IDependencyObject * pSender, struct Xcp_IDependencyObject * pEventArgs);
	static HRESULT RightTappedEventListener(struct Xcp_IDependencyObject * pSender, struct Xcp_IDependencyObject * pEventArgs);
	HRESULT SetAssociatedVisualTree(VisualTree * pVisualTree);
	VisualTree * GetAssociatedVisualTree();
	HRESULT GetAssociatedPopupRoot(CPopupRoot * * ppPopupRoot);
	HRESULT GetAssociatedInputManager(CInputManager * * ppInputManager);
	HRESULT GetAssociatedFocusManager(CFocusManager * * ppFocusManager);
	HRESULT GetAssociatedLayoutManager(CLayoutManager * * ppLayoutManager);
	HRESULT GetAssociatedPublicRoot(struct Xcp_IDependencyObject * * ppPublicRoot);
protected: 
	virtual HRESULT MeasureOverride(struct XSIZEF availableSize, struct XSIZEF & desiredSize);
	virtual HRESULT ArrangeOverride(struct XSIZEF finalSize, struct XSIZEF & newFinalSize);
	virtual HRESULT UpdateLayoutClip(XBOOL forceClipToRenderSize);
	virtual void NWPropagateDirtyFlag(enum DirtyFlags::Value flags);
	virtual HRESULT GenerateChildOuterBounds(struct XRECTF_RB * pBounds);
private: 
	VisualTree * m_pVisualTree;
	static const XUINT32 textControlEventsTypes[0];


};
